<template>
  <view class="content">
    <image class="logo" src="/static/logo.png" />
    <view class="text-area">
      <text class="title">{{ title }} </text>
    </view>
    <button @tap="postMessage">发送消息</button>
    <button class="btn" type="button" data-action="navigateBack" @tap="goBack">navigateBack</button>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const title = ref('Hello')

const postMessage = () => {
  console.log(webview)
  
  // const mini = window.jWeixin.miniProgram
  // console.log(mini)
  // uni.getEnv(function (res) {
  //   console.log('当前环境：' + JSON.stringify(res))
  // })
  webview.postMessage({
    data: {
      action: 'message'
    }
  })
}

const goBack = () => {
  // const mini = window.jWeixin.miniProgram
  webview.navigateBack()
}
</script>

<style lang="scss">
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  width: 200rpx;
  height: 200rpx;
  margin: 200rpx auto 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>
